﻿using System;

namespace Wisdom.Core
{
    public class PerRequestTasksRegistry : TasksRegistry, IPerRequestTasksRegistry
    {
        public IPerRequestTasksRegistry Include<TTask>() where TTask : PerRequestTask
        {
            return Include<TTask>(null);
        }

        public IPerRequestTasksRegistry Include<TTask>(Action<TTask> configure) where TTask : PerRequestTask
        {
            Action<object> modified = null;

            if (configure != null)
            {
                modified = t => configure((TTask)t);
            }

            Include(typeof(TTask), modified);

            return this;
        }
    }
}